// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
// 登录表单验证：不能为空
var Login = {
    buttonAble: function() {
        var username_value = $("#user_session_username").attr("value");
        var password_value = $("#user_session_password").attr("value");
        if(username_value !='' && password_value != '' && password_value.length > 3){
            // $(":submit").attr("disabled",false);
            $("#user_session_submit").removeAttr("disabled");
        }else {
            $("#user_session_submit").attr("disabled",true);
        }
    }
}
//淡出消息框
var fadeOutMsgBox = function() {
    $("#nav_msg").fadeOut(4000);//4000毫秒淡出
}

var LogAdmin = {
    //获取日志内容
    getLogSource: function(log_path) {
        $.ajax({
            url: "/site/log_admin",
            data: "log_path=" + log_path,
            beforeSend: function(){
                $("#log_area").empty();
                $("#log_area").append("<img src=\"/images/roller.gif\" />")
            },
            success: function(date){
                $("#log_area").empty();
                $("#log_area").append("<textarea style=\"width:98%; height: 380px; font-size:12px;\">"+date+"</textarea>");
            },
            error: function(){
                $("#log_area").empty();
                $("#log_area").append("<span style=\"color:red\">获取日志失败！</span>");
            }
        });
    },
    clearLog: function(clear_path,update_div) {
        $.ajax({
            url: "/site/log_admin",
            data: "clear_path=" + clear_path,
            beforeSend: function(){
                $("#"+update_div).empty();
                $("#"+update_div).append("<img style=\"width:20px; height:20px;\" src=\"/images/roller.gif\" />")
            },
            success: function(date){
                $("#"+update_div).empty();
                $("#"+update_div).append(date);
            },
            error: function(){
                $("#"+update_div).empty();
                $("#"+update_div).append("<span style=\"color:red\">清空失败！</span>");
            }
        });
    }
}